<?php
namespace system\admin\controller;

class Index{

   //登录
    public function index(){
        //模板
        require view('default/index/login.php');

    } 


   //登录查验
   public function login_check(){

        if( isset($_POST['username']) && $_POST['username']!='' && isset($_POST['password']) && $_POST['password']!='' ){
            $username = $_POST['username'];
            $password = substr(md5($_POST["password"]),15,25);
            $sql="select * from " . tablename('sys_admin') . " where login_account = '".$username."' and login_password = '".$password."' ";
            $ret = $GLOBALS["db"]->query($sql)->fetch();
            if(!empty($ret)){
                $_SESSION['uid'] = $ret['user_id'];
                $arr['code']=1;
                $arr['msg']='登录成功!';
                $arr['data']='';
            }else{
                $arr['code']=0;
                $arr['msg']='账号或密码错误!';
                $arr['data']='';
            }
        }else{
            $arr['code']=0;
            $arr['msg']='账号或密码为空!';
            $arr['data']='';
        }
        exit(json_encode($arr));
    } 

}